package org.jeecg.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.entity.SdsiPeopleRy;
import org.jeecg.service.PeopleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Api(tags="动态更新人员表")
@RestController
@RequestMapping("/dtgx")
@Slf4j
public class PeopleController {

    @Autowired
    private PeopleService peopleService;

    /**
     * 分页列表查询
     *
     * @param sdsiPeopleRy
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "人员表-分页列表查询")
    @ApiOperation(value="人员表-分页列表查询", notes="人员表-分页列表查询")
    @GetMapping(value = "/list")
    public Result<?> queryPageList(SdsiPeopleRy sdsiPeopleRy,
                                   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                   HttpServletRequest req) {
        QueryWrapper<SdsiPeopleRy> queryWrapper = QueryGenerator.initQueryWrapper(sdsiPeopleRy, req.getParameterMap());
        Page<SdsiPeopleRy> page = new Page<SdsiPeopleRy>(pageNo, pageSize);
        IPage<SdsiPeopleRy> pageList = (IPage<SdsiPeopleRy>) peopleService.queryPageList(sdsiPeopleRy,pageNo, pageSize,req);
        return Result.OK(pageList);
    }
}
